home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 August: Tool Chest / Dev.CD Aug 94.toast / New System Software Extensions / OpenDoc A6 / OpenDoc Parts Framework / OPF / OS / FWGraphx / Include / FWLinShp.h < prev    next >
Encoding:
Text File  |  1994-04-21  |  4.7 KB  |  173 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                FWLinShp.h
  4. //    Release Version:    $ 1.0d1 $
  5. //
  6. //    Creation Date:        3/28/94
  7. //
  8. //    Copyright:    © 1993, 1994 by Apple Computer, Inc., all rights reserved.
  9. //
  10. //========================================================================================
  11.  
  12. #ifndef FWLINSHP_H
  13. #define FWLINSHP_H
  14.  
  15. #ifndef FWSHAPE_H
  16. #include "FWShape.h"
  17. #endif
  18.  
  19. #ifndef FWRECT_H
  20. #include "FWRect.h"
  21. #endif
  22.  
  23. #ifndef FWINK_H
  24. #include "FWInk.h"
  25. #endif
  26.  
  27. #ifndef FWSTYLE_H
  28. #include "FWStyle.h"
  29. #endif
  30.  
  31. //==============================================================================
  32. //    •• Forward Declarations
  33. //==============================================================================
  34.  
  35. class FW_CGraphicContext;
  36. class XMPTransform;
  37. class FW_CLineShapeRep;
  38. class FW_COvalShape;
  39. class FW_CRoundRectShape;
  40. class FW_CArcShape;
  41. class FW_CRectShape;
  42. class FW_CRegionShape;
  43.  
  44. //==============================================================================
  45. //    •• CLASS FW_CLineShape
  46. //==============================================================================
  47.  
  48. class FW_CLineShape : public FW_CShape
  49. {
  50. //------------------------------------------------------------------------------
  51. //    • Constructors
  52. //
  53. public:
  54.     FW_CLineShape();
  55.     FW_CLineShape(const FW_CPoint& start, const FW_CPoint& end);
  56.             
  57.     FW_CLineShape(const FW_CLineShape& other);
  58.     FW_CLineShape(FW_CLineShapeRep* rep);
  59.  
  60. //-------------------------------------------------------------------------------
  61. //    • Operators
  62. //
  63. public:
  64.     FW_CLineShape& operator=(const FW_CLineShape& other);
  65.     FW_CLineShape& operator=(FW_CLineShapeRep* other);
  66.     FW_CLineShapeRep* operator->() const
  67.                 {return (FW_CLineShapeRep*)GetRep();}
  68.  
  69. //----------------------------------------------------------------------------------------
  70. //    • Conversion
  71. //
  72. public:
  73.     operator FW_COvalShape() const;
  74.     operator FW_CRoundRectShape() const;
  75.     operator FW_CArcShape() const;
  76.     operator FW_CRectShape() const;
  77.     operator FW_CRegionShape() const;
  78.  
  79. //------------------------------------------------------------------------------
  80. //    • Static Methods
  81. //
  82. public:
  83.     static void DrawLine(FW_CGraphicContext* graphicContext, 
  84.                         const FW_CPoint& start, 
  85.                         const FW_CPoint& end);
  86. };
  87.  
  88. //==============================================================================
  89. //    •• class FW_CLineShapeRep
  90. //==============================================================================
  91.  
  92. class FW_CLineShapeRep : public FW_CShapeRep
  93. {
  94.     friend class FW_CLineShape;
  95.     
  96. //------------------------------------------------------------------------------
  97. //    • Constructors/Destructors
  98. //
  99. protected:
  100.     FW_CLineShapeRep();
  101.     FW_CLineShapeRep(const FW_CPoint& start, const FW_CPoint& end);
  102.     
  103.     virtual ~FW_CLineShapeRep();
  104.  
  105. //------------------------------------------------------------------------------
  106. //    • Inherited API
  107. //
  108. public:
  109.     // ----- Rendering -----
  110.     virtual void    Draw(FW_CGraphicContext* graphicContext);
  111.     static void    DrawLine(FW_CGraphicContext* graphicContext,
  112.                             const FW_CPoint& start,
  113.                             const FW_CPoint& end);
  114.     
  115.     // ----- Hit Testing -----
  116.     virtual FW_HitTestPart HitTest(const FW_CPoint& test) const;
  117.     
  118.     // ----- Transform -----
  119.     virtual void    Transform(XMPTransform* transform);
  120.     virtual void    InverseTransform(XMPTransform* transform);
  121.  
  122.     virtual void    MoveShape(XMPCoordinate deltaX, XMPCoordinate deltaY);
  123.     virtual void    MoveShapeTo(XMPCoordinate x, XMPCoordinate y);
  124.  
  125.     // ----- Geometry -----
  126.     virtual FW_CRect GetShapeBounds() const;
  127.  
  128.     // ----- Default shape -----
  129.     virtual void     SetAsDefault() const;
  130.  
  131.     // ----- Stream -----
  132.     virtual void    Flatten(FW_CWritableStream& stream);
  133.     virtual void    Unflatten(FW_CReadableStream& stream);
  134.  
  135. //------------------------------------------------------------------------------
  136. //    • New API
  137. //
  138. public:
  139.     FW_CLineShape    Copy() const;
  140.  
  141.     FW_CPoint        GetLineStart() const
  142.                         {return fStart;}
  143.     FW_CPoint        GetLineEnd() const
  144.                         {return fEnd;}
  145.     
  146.     void            SetLineStart(const FW_CPoint& start)
  147.                         {fStart = start; Changed();}
  148.     void            SetLineEnd(const FW_CPoint& end)
  149.                         {fEnd = end; Changed();}
  150.     
  151. //------------------------------------------------------------------------------
  152. //    • Data Members
  153. //
  154. private:
  155.     FW_CPoint        fStart;
  156.     FW_CPoint        fEnd;
  157. };
  158.  
  159. //==============================================================================
  160. //    •• Inlines
  161. //==============================================================================
  162.  
  163. //------------------------------------------------------------------------------
  164. //    • FW_CLineShape::DrawLine
  165. //------------------------------------------------------------------------------
  166. inline static void FW_CLineShape::DrawLine(FW_CGraphicContext* graphicContext, 
  167.                                             const FW_CPoint& start, 
  168.                                             const FW_CPoint& end)
  169. {
  170.     FW_CLineShapeRep::DrawLine(graphicContext, start, end);
  171. }
  172.  
  173. #endif